package com.app.configuration.web.mvc;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.app.configuration.web.mvc.interceptors.UserRightsInterceptor;
import com.app.util.common.ObjUtil;

/**
 * 拦截器配置
 * @author chenl
 *
 */
@Configuration
public class WebMvcInterceptorConfiguration  implements WebMvcConfigurer {
	
	@Autowired
	UserRightsInterceptor userRightsInterceptor;
	
	
	@Value("${userRightInterceptor.excludePath}")
	private String excludePath;
	
	
	/**
	 * 设置拦截器
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// TODO Auto-generated method stub
		
		List<String> excludePathList = ObjUtil.strToList(excludePath);
		//设置拦截器
		registry.addInterceptor(userRightsInterceptor).addPathPatterns("/**").excludePathPatterns(excludePathList);
		
		WebMvcConfigurer.super.addInterceptors(registry);
	}
	
	
	
	
}
